package com.effectiv.gooruda.rest.service.api;


import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.effectiv.gooruda.rest.docs.annotation.Api;
import com.effectiv.gooruda.rest.docs.annotation.ApiHeaders;
import com.effectiv.gooruda.rest.docs.annotation.ApiHeader;
import com.effectiv.gooruda.rest.docs.annotation.ApiMethod;
import com.effectiv.gooruda.rest.docs.annotation.ApiParam;
import com.effectiv.gooruda.rest.docs.annotation.ApiResponseObject;
import com.effectiv.gooruda.rest.docs.pojo.ApiVerb;


@Path("/data")
@Api(name = "Data API", description = "Data mangement and query API.")
public abstract class DataStorageService {
	
	/**
	 * Save a new document in the data store.
	 * @param collection
	 * @param data
	 * @return
	 */
	@ApiMethod(path = "/api/data", verb = ApiVerb.POST, description = "Save a new document in the data store.", 
			produces = { MediaType.APPLICATION_JSON }, consumes = { MediaType.APPLICATION_JSON })
	@ApiHeaders(headers = {
			@ApiHeader(name = "signature", description = "Authentication signature."),
			@ApiHeader(name = "public-key", description = "Public key of the application.") })
	
	@Path("/{collection}")
	@POST
	public abstract  @ApiResponseObject Response save(
			@PathParam("collection")  @ApiParam(name="collection", description="Name of the collection.") String collection, String data);
	
	
	/**
	 * Query for documents in a given collection
	 * @param collection
	 * @param query
	 * @return
	 */
	
	@ApiMethod(path = "/api/findall/{collection}/{query}", verb = ApiVerb.GET, description = "Query for documents in a given collection.", 
			produces = { MediaType.APPLICATION_JSON }, consumes = { MediaType.APPLICATION_JSON })
	@ApiHeaders(headers = {
			@ApiHeader(name = "signature", description = "Authentication signature."),
			@ApiHeader(name = "public-key", description = "Public key of the application.") })
	
	@Path("/findall/{collection}/{query}")
	@GET
	public abstract  @ApiResponseObject Response findAll(
			@PathParam("collection")  @ApiParam(name="collection", description="Name of the collection.") String collection,
			@PathParam("query")  @ApiParam(name="query", description="Query.") String query);
	
	
	
}
